package components.map.info
{
	import capricornus.components.ComponentsManager;
	
	import components.map.MapController;
	
	import flash.events.MouseEvent;

	public class MapInfoPopupController
	{
		private var _view:MapInfoPopupView;
		
		public function MapInfoPopupController()
		{
			init();
		}
		
		private function init():void
		{
			_view = new MapInfoPopupView( ComponentsManager.instance.popupLayer );
			
			_view.btnOK.addEventListener( MouseEvent.CLICK, onClickOK, false, 0, true );
		}
		
		public function show():void
		{
			_view.setCenterLocation();
			_view.show();
		}
		
		private function onClickOK( e:MouseEvent ):void
		{
			MapController.instance.createNewMap( _view.txtName.text, int(_view.txtWidth.text), int(_view.txtHeight.text), int(_view.txtGridWidth.text), int(_view.txtGridHeight.height) );
			_view.close();
		}
	}
}